﻿using DevTeam;

using System;
namespace ConfExpert.Forms.Rapor.YeniYapi
{
    public partial class TelaTopEtiketleri : XRapor
    {
        public TelaTopEtiketleri()
        {
            InitializeComponent(); 
        }

        private void Form_Load(object sender, EventArgs e)
        {
            
            //lblProc.Text = "";
            this.Text = "Tela Top Etiketleri";

            gv.Init("GetBarcodeHistory2", 21);
            gv.Click += new EventHandler(gv_Click);
            gv.MakeColumnInvisible("BarcodeHistoryId","Numune");
            gv.Columns["ModifiedOn"].Visible = true;
            btnPreview.ItemClick += btnPreview_ItemClick;
            gv.MakeReadOnly();
            gv.BestFitColumns();
        }

        void btnPreview_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (txtRollId13.EditValue.ToStr().Trim() != String.Empty)
            {
                TelaBarkod barcode = new TelaBarkod(Enums.EtiketTipi.RollId, txtRollId13.EditValue.ToStr());
                ReportViewer.View(barcode);
            }
        }

        void gv_Click(object sender, EventArgs e)
        {
            if (gv.FocusedRowHandle > -1)
            {
                string liste = gv.GetFocusedRowCellValue("GelisPartisiId").ToString();
                if (liste.Substring(liste.Length - 1) == ",")
                    liste = liste.Substring(0, liste.Length - 1);
                TelaBarkod barcode = new TelaBarkod(Enums.EtiketTipi.GelisPartisiId, liste);
                ReportViewer.View(barcode);
            }
        }

        private void btnGuncelle_Click(object sender, EventArgs e)
        {
            gv.RefreshDataSource("GetBarcodeHistory2", 21);
            gv.BestFitColumns();
        }
    }
}